﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using WXDba.Entity;
namespace WXDba.Abstract
{
    public interface IWXUser : IBaseAbstract<WXUser>
    {
        #region 获取对象
        /// <summary>
        /// 盘点openid，是否已经存在
        /// </summary>
        /// <param name="OpenID">当前用户的OPENID</param>
        /// <returns></returns>
        bool IsExists_OpenID(string OpenID);
        /// <summary>
        /// 判断UnionID，是否已经存在
        /// </summary>
        /// <param name="UnionID"></param>
        /// <returns></returns>
        bool IsExists_UnionID(string UnionID);
        /// <summary>
        /// 获取OpenID对象的用户对象
        /// </summary>
        /// <param name="OpenID">当前OpenID</param>
        /// <returns></returns>
        WXUser GetModel_OpenID(string OpenID);
        /// <summary>
        /// 获取UnionID对应的用户对象
        /// </summary>
        /// <param name="UnionID"></param>
        /// <returns></returns>
        WXUser GetModel_UnionID(string UnionID);
        #endregion

        #region 扩展接口
        /// <summary>
        /// 批量添加 微信用户列表的OpenID
        /// </summary>
        /// <param name="OpenIDList"></param>
        bool AddOpenIDList(List<string> OpenIDList);
        /// <summary>
        /// 添加或修改对象
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        bool AddOrUpdate(WXUser model);
        /// <summary>
        /// 添加或修改对象（授权用户信息）
        /// </summary>
        /// <param name="oauth">授权用户信息</param>
        /// <returns></returns>
        WXUser AddOrUpdate(OAuthUser oauth);
        /// <summary>
        /// 根据OpenID，同步用户对象
        /// </summary>
        /// <param name="newModel">新对象</param>
        /// <returns></returns>
        bool Update(WXUser newModel);
        /// <summary>
        /// 修改用户的备注
        /// </summary>
        /// <param name="OpenID">OpenID</param>
        /// <param name="Remarik">备注内容</param>
        /// <returns></returns>
        bool UpdateRemark(string OpenID, string Remarik);
        /// <summary>
        /// 修改用户分组
        /// </summary>
        /// <param name="idList">OpenID</param>
        /// <param name="GroupID">用户分组ID</param>
        /// <returns></returns>
        bool UpdateGroup(List<string> idList, int GroupID);
        #endregion

        #region 获取列表
        /// <summary>
        /// 获取用户分页列表
        /// </summary>
        /// <param name="info">分页信息</param>
        /// <param name="NickName">用户昵称</param>
        /// <param name="Subscribe">是否关注了公众号</param>
        /// <returns></returns>
        List<WXUser> GetPage(PageInfo info, string NickName = null, bool? Subscribe = null);
        /// <summary>
        /// 遍历数据库所有的OpenID，100个位单位，每次遍历成功触发onPageSuccess
        /// </summary>
        /// <param name="onPageSuccess"></param>
        void ForeachOpenID(Action<List<string>> onPageSuccess);
        #endregion


        #region 获取数量
        /// <summary>
        /// 获取关注的用户总量
        /// </summary>
        /// <returns></returns>
        int GetCount();
        #endregion
    }
}
